/**
 * Created by ACER on 2017/4/16.
 */
/**
 * Created by ACER on 2017/4/16.
 */
app.controller('forgetpwd',function($scope,$http){
    //用户邮箱
    $scope.email = '';
    //用户新密码
    $scope.newpassword = '';
    $scope.verificationCode='';

    $scope.forgetEmailPassword = function(){
        var registerInfo = {'email':$scope.email,'newpassword':$scope.newpassword,'verificationCode':$scope.verificationCode};
        $http({
            method:'post',
            url:app.netPath+'/users/resetPasswordByEmail',
            params:registerInfo
        }).then(function(res){
            console.log(res);
            if(!res.data.error){
                $.toast('密码重置成功')
                location.href='#login'
            }else{
                $.toast(res.data.msg);
                return;
                }
        },function(){
            $.toast('网络走丢了！')
        })
    };

    $scope.getVerificationCode=function(){
        var email={'email':$scope.email};
        $http({
            method:'get',
            url:app.netPath+'/users/getVerificationCode',
            params:email
        }).then(function(res){
            if(!res.data.error){
                $.toast('验证码发送成功');
            }else{
                $.toast("验证码发送失败");
            }
        },function(){

            $.toast('网络有问题哟');
        })
    }

});